package com.admin.controller.system;

import com.admin.common.enums.EnumResult;
import com.admin.controller.base.BaseController;
import com.admin.domain.DeclareSwitchLog;
import com.admin.domain.SysParam;
import com.admin.req.system.SwitchReq;
import com.admin.service.SysParamService;
import com.admin.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 系统管理员接口
 * 
 * @author ZY
 * @date 2018/09/30
 */
@Api(description = "系统参数接口")
@RestController
@RequestMapping(value = "/sysParam")
public class SysParamController extends BaseController {

    private Logger logger = LoggerFactory.getLogger(SysParamController.class);

    @Autowired
    private SysParamService sysParamService;

//    @RequiresPermissions("sysParam:update")
    @ApiOperation(value = "修改申报权限开关")
    @PostMapping(value = "/updateSwitch")
    public ResultVO<Boolean> updateSwitch(@RequestBody SwitchReq switchReq) {
        return ResultVO.ok(sysParamService.updateSwitch(switchReq));
    }


//    @RequiresPermissions("sysParam:list")
    @ApiOperation(value = "业务配置-申报时间设置 - 申报开关")
    @GetMapping(value = "/declareSwitch")
    public ResultVO toList() {
        ResultVO result = new ResultVO();
        result.setData(sysParamService.declareSwitch());
        result.setCode(EnumResult.SUCCESS.getCode());
        result.setMsg(EnumResult.SUCCESS.getMsg());
        return result;
    }

    @ApiOperation(value = "业务配置-申报时间设置 - 操作日志")
    @GetMapping(value = "/declareSwitchLogs")
    public ResultVO<DeclareSwitchLog> declareSwitchLogs() {
        ResultVO result = new ResultVO();
        result.setData(sysParamService.getSwitchLogs());
        result.setCode(EnumResult.SUCCESS.getCode());
        result.setMsg(EnumResult.SUCCESS.getMsg());
        return result;
    }


}
